/*
 * UserNet  --  TCP/IP implementation in userspace
 * Copyright (C) 2010  Robert Millan
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef UNET_IPC_H
#define UNET_IPC_H

#include <sys/un.h>
#include <sys/types.h>		/* pid_t, uid_t */
#include <netinet/in.h>		/* struct in_addr */

#define SERVER_SOCKET	"/var/run/unet.socket"

#ifdef _UNET_SERVER
extern int unet_ipc_listen ();
extern int unet_ipc_accept (int fd, pid_t *pid, uid_t *uid);
extern ssize_t unet_ipc_read (int fd, void *msg, size_t n);
extern ssize_t unet_ipc_write (int fd, const void *msg, size_t n);
#endif

#ifdef _UNET_CLIENT
extern int unet_ipc_connect () __attribute__ ((warn_unused_result));
#endif

#endif
